package com.backend.modules.system.repository;

import com.backend.modules.system.entity.SysTeacherClass;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SysTeacherClassRepository extends JpaRepository<SysTeacherClass, Long> {
    
    List<SysTeacherClass> findByTeacherId(Long teacherId);
    
    List<SysTeacherClass> findByClassId(Long classId);
    
    void deleteByTeacherId(Long teacherId);
    
    @Query("SELECT DISTINCT tc.classId FROM SysTeacherClass tc WHERE tc.teacherId = ?1")
    List<Long> findClassIdsByTeacherId(Long teacherId);
    
    @Query("SELECT DISTINCT tc.teacherId FROM SysTeacherClass tc WHERE tc.classId IN ?1")
    List<Long> findTeacherIdsByClassIds(List<Long> classIds);

    Integer countByTeacherId(Long teacherId);

    void deleteByClassIdIn(List<Long> collect);
}